/*
 * RtpMedium.h
 *
 *  Created on: 2015年7月18日
 *      Author: terry
 */

#ifndef MEDIA_RTPMEDIUM_H_
#define MEDIA_RTPMEDIUM_H_

#include "BasicType.h"
#include <string>


class RtpMedium
{
public:

	enum StreamMode
	{
	    kNone = 0,
	    kRecvOnly = 0x01,
	    kSendOnly = 0x02,
	    kSendRecv = 0x03,
	    kInactive = 0
	};

	enum SetupMode
	{
		kPassive,
		kActive
	};

	static const char*	VIDEO;
	static const char*	AUDIO;

	static const char*	H264;
	static const char*	H265;
	static const char*	PS;

	static const char*	PCMA;
	static const char*	PCMU;

	static const char*	RTP_AVP;
	static const char*	RTP_AVP_TCP;
	static const char*	TCP_RTP_AVP;

	static const char*  active;
	static const char*  passive;

	static const char* getModeName(int mode);

	static int getPeerMode(int mode);

	static std::string getPeerSetup(const std::string& setup);

	static int getPayload(const std::string& codec);

public:
	std::string name;	/// 媒体名称
	std::string  protocol;	/// 协议

	std::string ip;		/// 连接地址
	int	port;			/// 连接端口

	int payload;		/// 载体类型
	std::string codec;	/// 编码名称

	int clockRate;		/// 时钟
    int channel;
	int mode;			/// 媒体流方向

	std::string params;
    int width;			/// 宽
    int height;			/// 高

    uint32_t ssrc;		/// SSRC ID
    std::string	setup;

	RtpMedium():
		port(),
		payload(),
		clockRate(90000),
        channel(),
		mode(),
        width(),
        height(),
		ssrc(),
		protocol(RTP_AVP),
		setup()
	{
	}

	bool empty() const
	{
		return (port == 0) || (name.empty());
	}

	void clear()
	{
		port = 0;
		payload = 0;
		clockRate = 90000;
        channel = 0;
		mode = 0;
		width = 0;
		height = 0;
		ip.clear();
		protocol = RTP_AVP;
	}


};


#endif /* MEDIA_RTPMEDIUM_H_ */
